/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jpa.entities;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author innovapps.co
 */
@Entity
@Table(name = "maquina")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Maquina.findAll", query = "SELECT m FROM Maquina m"),
    @NamedQuery(name = "Maquina.findByIdMaquina", query = "SELECT m FROM Maquina m WHERE m.idMaquina = :idMaquina"),
    @NamedQuery(name = "Maquina.findByDescrMaquina", query = "SELECT m FROM Maquina m WHERE m.descrMaquina = :descrMaquina")})
public class Maquina implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_maquina")
    private Integer idMaquina;
    @Basic(optional = false)
    @Column(name = "descr_maquina")
    private String descrMaquina;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "maquinaIdMaquina")
    private List<Certificacion> certificacionList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "maquinaIdMaquina")
    private List<InformeSoldadura> informeSoldaduraList;

    public Maquina() {
    }

    public Maquina(Integer idMaquina) {
        this.idMaquina = idMaquina;
    }

    public Maquina(Integer idMaquina, String descrMaquina) {
        this.idMaquina = idMaquina;
        this.descrMaquina = descrMaquina;
    }

    public Integer getIdMaquina() {
        return idMaquina;
    }

    public void setIdMaquina(Integer idMaquina) {
        Integer oldIdMaquina = this.idMaquina;
        this.idMaquina = idMaquina;
        changeSupport.firePropertyChange("idMaquina", oldIdMaquina, idMaquina);
    }

    public String getDescrMaquina() {
        return descrMaquina;
    }

    public void setDescrMaquina(String descrMaquina) {
        String oldDescrMaquina = this.descrMaquina;
        this.descrMaquina = descrMaquina;
        changeSupport.firePropertyChange("descrMaquina", oldDescrMaquina, descrMaquina);
    }

    @XmlTransient
    public List<Certificacion> getCertificacionList() {
        return certificacionList;
    }

    public void setCertificacionList(List<Certificacion> certificacionList) {
        this.certificacionList = certificacionList;
    }

    @XmlTransient
    public List<InformeSoldadura> getInformeSoldaduraList() {
        return informeSoldaduraList;
    }

    public void setInformeSoldaduraList(List<InformeSoldadura> informeSoldaduraList) {
        this.informeSoldaduraList = informeSoldaduraList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idMaquina != null ? idMaquina.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Maquina)) {
            return false;
        }
        Maquina other = (Maquina) object;
        if ((this.idMaquina == null && other.idMaquina != null) || (this.idMaquina != null && !this.idMaquina.equals(other.idMaquina))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return descrMaquina;
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
